function getInfo (url, type) {
  return new Promise((resolve, reject) => {
    const xhr = new XMLHttpRequest()
    xhr.responseType = type
    xhr.open('get', url, true)
    xhr.onload = () => {
      if (xhr.status >= 200 && xhr.status < 300) {
        res(xhr.response)
      } else {
        rej(new Error(xhr.statusText))
      }
    }
    xhr.send()
  })
}

export {getInfo}
